/*******************************************************************************
 * Copyright (c) 2012 Clever Devices.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 * 	Clever Devices Interns - 
 * 	Alex Frankel, Andria Young, Kevin Thomas, Nicholas Culpepper, Taner Oztimurlenk, Thomas Volberg
 ******************************************************************************/
package com.framework.bustime;

import com.framework.cleverstop_tentative.BusTimeMainActivity;
import com.framework.cleverstop_tentative.R;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;


/**
 * 
 * Not Used.  This was to implement the timed alert for the demo.  Was unable to
 * get the onReceive method to be called
 * 
 * @author AFrankel
 *
 */
public class BusTimeBroadcastReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		NotificationManager nm = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);

		Intent i = new Intent(context, BusTimeMainActivity.class);
		PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0);
		String body = "You will be arriving in 1 minute";
		String title = "Prediction Alarm";
//		Drawable d = context.getResources().getDrawable(R.drawable.alert);
//		Bitmap icon = BitmapFactory.decodeResource(context.getResources(),
//				R.drawable.alert);
		// Notification n = new
		// Notification.Builder(this).setContentTitle("title").setContentText(body)
		// .setSmallIcon(R.drawable.alert).setLargeIcon(icon);

		Notification n = new Notification(R.drawable.alert, body,
				System.currentTimeMillis());
		n.setLatestEventInfo(context, title, body, pi);
		n.defaults = Notification.DEFAULT_ALL;
		nm.notify(uniqueID, n);
		nm.cancel(uniqueID);
		
		
		
	}
	
	private static int uniqueID = 123456789;

}
